<template>
  <div class="create-activity">
    <h2>创建新活动</h2>
    <form @submit.prevent="createActivity">
      <div>
        <label for="title">标题：</label>
        <input type="text" id="title" v-model="title" required />
      </div>
      <div>
        <label for="description">描述：</label>
        <textarea id="description" v-model="description" required></textarea>
      </div>
      <div>
        <label for="date">日期：</label>
        <input type="date" id="date" v-model="date" required />
      </div>
      <div>
        <label for="location">地点：</label>
        <input type="text" id="location" v-model="location" required />
      </div>
      <button type="submit">创建活动</button>
    </form>
  </div>
</template>

<script>
import activities from '../data/activities.js';

export default {
  data() {
    return {
      title: '',
      description: '',
      date: '',
      location: ''
    };
  },
  methods: {
    createActivity() {
      const newActivity = {
        id: activities.length + 1,
        title: this.title,
        description: this.description,
        date: this.date,
        location: this.location
      };
      activities.push(newActivity);
      this.$router.push('/activity-management');
    }
  }
};
</script>